<%#
  # WebROaR - Ruby Application Server - http://webroar.in/
  # Copyright (C) 2009  Goonj LLC
  #
  # This file is part of WebROaR.
  #
  # WebROaR is free software: you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # WebROaR is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with WebROaR.  If not, see <http://www.gnu.org/licenses/>.
  #%>
<script>
function loadDivs(arr) {
  for ( i = 0 ; i < arr.length ; i=i+2) {
    if(document.getElementById(arr[i]) != null){
      document.getElementById(arr[i]).innerHTML = arr[i+1];
    }
  }
}
</script>

    <br/>
    <div id = "page_name"><%=image_tag("title_home_15_06_2011.gif")%></div>
    <br/> 
    <span id='update_data'></span> 
    <table width = 95% align='center' >
      <tr>
        <th colspan = 2>Server Snapshot </th>
      </tr>
      <tr>
        <td  >CPU Usage</td>
        <td  ><span id = 'server_cpu_usage'><%="%.2f" % @server_resource_usage[0]%></span> %</td>
      </tr>
      <tr>
        <td  >Memory Usage</td>
        <td  ><span id = 'server_memory_usage'><%=format("%.2f",@server_resource_usage[1]/1024.to_f)%></span> MB</td>
      </tr>
    </table>
    <br/><br/>
    <table width = 95% align='center'>
      <%if @info and @info['Application Specification']%>						
        <tr>
          <th colspan = 6>Deployed Applications</th>
        </tr>
        <tr>
          <td class = "sub_header text_align_center" width = "25%">Application Name</td>
          <td class = "sub_header text_align_center" width = "15%">CPU Usage</td>
          <td class = "sub_header text_align_center" width = "15%">Memory Usage</td>
          <td class = "sub_header text_align_center" width = "15%">Minimum Workers</td>
          <td class = "sub_header text_align_center" width = "15%">Maximum Workers</td>	
          <td class = "sub_header text_align_center" width = "15%">New Exceptions</td>	
        </tr> 	
        <%=raw(application_list_home)%>
      <%else%>
        <tr>
          <th colspan = 5>&nbsp;</th>
        </tr>
        <tr>
          <td colspan = 5 style="text-align:center;"><%=NO_DEPLOYED_APPLICATION_MESSAGE%><br/> Please use <%=link_to 'Configuration', :controller => 'admin', :action => 'configuration'%> tab to deploy applications.</td>
        </tr>
      <%end%>
  </table>
<%= periodically_call_remote( :update => 'update_data', :url =>{ :controller => 'admin', :action => 'get_latest_updates'}, :frequency => 60)%>
